/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package e.z.blog.back.com.impl.dao;

import e.z.blog.back.com.DaoManagerApi;
import e.z.blog.back.bean.system.Manager;
import java.util.List;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

/**
 *
 * @author EnzoZhong
 */
@IocBean
public class DaoManager implements DaoManagerApi {

        @Inject
        private Dao dao;

        @Override
        public Boolean verfiy ( Manager admin ) {
                String account = admin.getAccount();
                String password = admin.getPassword();
                if ( password.length() < 32 ) {
                        admin.encrypt();
                        password = admin.getPassword();
                }
                Cnd cnd = Cnd.where( "account" , "=" , account ).and( "password" , "=" , password );
                return dao.fetch( Manager.class , cnd ) != null;

        }

        @Override
        public Manager create ( Manager type ) {
                throw new UnsupportedOperationException( "Not supported yet." );
        }

        @Override
        public Manager read ( Manager type ) {
                throw new UnsupportedOperationException( "Not supported yet." );
        }

        @Override
        public List<Manager> readAll () {
                throw new UnsupportedOperationException( "Not supported yet." );
        }

        @Override
        public Manager update ( Manager type ) {
                throw new UnsupportedOperationException( "Not supported yet." );
        }

        @Override
        public Manager delete ( Manager type ) {
                throw new UnsupportedOperationException( "Not supported yet." );
        }
}
